Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@mintbase-js/sdk
Advanced tools
[//]: # { "title": "@mintbase-js/sdk", "order": "0" }
The core @mintbase-js/sdk
is a set of convenience wrappers around invocation of Mintbase smart contract methods.
It also exposes a low-level isomorphic execute method that can be passed raw NearContractCall
information.
In order to invoke a smart contract method, the transaction has to be signed using a public/private key pair.
There are two options, both provided from the @mintbase-js/auth module:
The easiest way to call mintbase token and market contracts are with the convenience methods.
Details such as the method name, arguments, gas supplied, deposits and some other less than convenient aspects of blockchain development will be abstracted away for you, or at least well documented in each example.
{% hint style="warning" %} This is a work in progress, please reach out to us on Telegram for support. {% endhint %}
execute
The excecute
method can be used without api helpers, however you will need to specify all NearContractCall
properties.
The method accepts any number of contract calls as arguments after the signingOptions
argument in first position:
execute(
signingOptions: NearCallSigningOptions
calls: NearContractCall[],
): Promise<providers.FinalExecutionOutcome | providers.FinalExecutionOutcome[]>
Here is an example using the execute function call:
This type specifies properties of a contract calls. Each of the API convenience methods returns this object type, however you are welcome to create this object manually:
{% code title="executeContractMethod.ts" overflow="wrap" lineNumbers="true" %}
import { execute, MAX_GAS, ONE_YOCTO, transfer } from '@mintbase-js/sdk';
import { getWallet } from '@mintbase-js/auth';
import type {
NearContractCall,
NearCallSigningOptions,
FinalExecutionOutcome
} from '@mintbase-js/sdk';
// create a contact call from scratch
const myCustomContractCall: NearContractCall<ExecuteArgsResponse>= {
// who should be signing the transaction
signerId: 'you.near',
// contract address
contractAddress: 'my.contract.address.near',
// the contract method name
methodName: 'my_contract_method',
// specify arguments for call_method
args: { },
// amount of gas to attach to the transactions
gas: MAX_GAS,
// the deposit to be sent along with the transaction
deposit: ONE_YOCTO,
};
// create a `NearContractCall` object using a helper method:
// note how this takes care of creating all the above properties
const transferCall = transfer({
nftContractId: 'mytokencontract.mintbase1.near',
transfers: [{
receiverId: 'bob.near',
tokenId: '123',
}],
})
const makeSmartContractCall = async (): Promise<FinalExecutionOutcome> => {
// to better understand signing options, read the auth module docs
// to use an account directly, you have to implement this method
// const account = await authenticateAccount('mynearaccount.near');
// before the getWallet can be called, you will need to setup context in the browser, it will throw otherwise
const wallet = await getWallet();
const options: NearExecuteOptions = {
// account
wallet,
callbackUrl: 'https://www.yourwebsite.xyz/success'
}
// call sign with options,
return await execute(options, myCustomContractCall, transferCall);
}
makeSmartContractCall()
.then((res: FinalExecutionOutcome) => console.log('got transaction result:', res))
.catch((err) => console.error('things went wrong', err));
{% endcode %}
When calling more than one method with execute the returned value will be a promise with an array of results Promise<FinalExecutionOutcome[]>
To use execute with batching all you need to do is supply as many calls as intended through arguments execute(sign, mint, transfer, mint, burn )
in this manner executions will happen in order.
Some api wrappers might be a composition of various contract calls that are often executed in succession like depositStorage
+ list
or revoke
+ unlist
.
The only difference is that in this case although you are technically calling execute with one method execute(sign, delist)
you will receive 2 outcome objects in the resulting promise.
If you would like to create a composition yourself you can do so like this.
const mintCall = mint({
nftContractId: 'placeholder',
ownerId: 'placeholder',
reference: 'placeholder',
});
const composed: NearContractCall = [mintCall, mintCall] as ContractCall[];
const result = execute(sign, composed) as FinalExecutionOutcome[];
{% hint style="warning" %}
Should you encounter this known issue Class PublicKey is missing in schema: publicKey
make sure you are not importing modules directly from near-api-js
, import them from @mintbase-js/sdk
instead to avoid the duplicate import.
{% endhint %}
FAQs
Core functions for Mintbase JS SDK
The npm package @mintbase-js/sdk receives a total of 1,547 weekly downloads. As such, @mintbase-js/sdk popularity was classified as popular.
We found that @mintbase-js/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.